import Vue from "vue";
import vant from "vant"; //导入组件
import "vant/lib/index.css";
import moment from "moment";
import App from "./App.vue";
import router from "./router";
import { serverUrl } from "./utils/tools";
import "./assets/main.scss";

Vue.prototype.$eventBus = new Vue(); //事件总线

Vue.use(vant); //用vue将该组件设置为全局可用

Vue.config.productionTip = false;

Vue.filter("dalImg", (url) => {
  if (url) {
    if (url.startsWith("http")) {
      return url;
    }
    return serverUrl + url;
  }
  return require("./assets/优菈.jpg"); //如果商品没有图片，这是需替换的图片
});

Vue.filter("formatDate", (date) => moment(date).format("YYYY-MM-DD HH:MM:SS"));

new Vue({
  router,
  render: (h) => h(App),
}).$mount("#app");
